<?php

/**
  * Autoload function
  * Manages "automatic" includes for classes definitions.
  * This function is called automatically by PHP.
  * This function may be modified if the user have libraries that
  * depends on it.
  * @package shakephp
  * @subpackage core
  * @param string $class_name Name of the required class
  */
function __autoload($class_name) {
	//Checking whether the class is a model
	if (array_key_exists($class_name, Config::$MODELS))
		require_once("models/".Config::$MODELS[$class_name]);
	//Checking whether the class is a controller
	elseif (array_key_exists($class_name, Config::$CONTROLLERS))
		require_once("controllers/".Config::$CONTROLLERS[$class_name]);
	//Checking whether the class is a user defined one
	elseif (array_key_exists($class_name, Config::$USER_CLASSES))
		require_once(Config::$USER_CLASSES[$class_name]);
	//Abstract Controller
	elseif($class_name=="Controller")
		require_once("framework/controller.inc.php");
	//View class
	elseif($class_name=="View")
		require_once("framework/view.inc.php");
}

?>
